//
//  QZInputYaoqingVC.m
//  shortvideoplay
//
//  Created by adam on 2024/9/30.
//

#import "QZInputYaoqingVC.h"

@interface QZInputYaoqingVC ()
@property (weak, nonatomic) IBOutlet YBTextFild *inputTF;
@property (weak, nonatomic) IBOutlet UIButton *sendeButton;
@property (weak, nonatomic) IBOutlet UILabel *tipLabel;

@end

@implementation QZInputYaoqingVC

- (void)showOldAddNavViewToMainOldView1{
    UIView * oldBgSS = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    oldBgSS.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:oldBgSS];
    
    UIButton * sendBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreen_W-75, kStatusBarHeight+10, 60, 46)];
    sendBtn.layer.cornerRadius = 3;
    sendBtn.backgroundColor = [UIColor whiteColor];
    [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [sendBtn setTitleColor:ColorHex(@"#333333") forState:UIControlStateNormal];
    sendBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [sendBtn addTarget:self action:@selector(sendTap) forControlEvents:UIControlEventTouchUpInside];
    [oldBgSS addSubview:sendBtn];
    
    UIView * sendBg = [[UIView alloc]initWithFrame:CGRectMake(15, kStatusBarHeight+66, KScreen_W-30, (KScreen_H-KSafeAreaBottomHeight-25-(kStatusBarHeight+66))/2)];
    sendBg.backgroundColor = [UIColor whiteColor];
    sendBg.layer.cornerRadius = 3;
    [oldBgSS addSubview:sendBg];
    
    UILabel * sendTip = [[UILabel alloc]initWithFrame:CGRectMake(0, (sendBg.frame.size.height-40)/2, sendBg.frame.size.width, 40)];
    sendTip.text = @"发送区";
    sendTip.textColor = ColorHex(@"#f0f0f0");
    sendTip.textAlignment = NSTextAlignmentCenter;
    sendTip.font = [UIFont systemFontOfSize:28];
    [sendBg addSubview:sendTip];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"我的邀请人";
    self.sendeButton.backgroundColor = MainColor;
    self.sendeButton.layer.cornerRadius = 20;
    self.sendeButton.clipsToBounds = YES;
    
    self.inputTF.attributedPlaceholder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"请输入你邀请人的邀请码", nil) attributes:@{NSForegroundColorAttributeName:COLOR_ALPH(255, 255, 255, 0.82),NSFontAttributeName:[UIFont systemFontOfSize:15]}];
    self.inputTF.layer.cornerRadius =22;
    self.inputTF.clipsToBounds = YES;
    self.inputTF.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 18, 44)];
    self.inputTF.leftViewMode = UITextFieldViewModeAlways;
    self.inputTF.backgroundColor = subviewback_black;
    
    self.tipLabel.text = @"1.下载软件后10天内可以输入邀请码，超过时间不能在输入；\n\n2.一台设备只能输入一个邀请码，已输入过邀请码的设备，切换账号也不能在提交邀请码。\n\n3.使用app分身软件，高包手机号等非正常用户，无法提交邀请码；";
    
}

- (IBAction)sendTap:(id)sender {
    if(self.inputTF.text.length < 6){
        [YBMsgPop showPop:@"请输入正确的邀请码"];
        return;
    }
    KMutableDic(sendDic)
    sendDic[@"code"] = self.inputTF.text;
    KWeakSelf
    [YBNetBase bindInviteRequest:sendDic successBlock:^(NSDictionary * _Nonnull data, NSInteger code, NSString * _Nonnull msg) {
        if(code == 200){
            [weakSelf.navigationController popViewControllerAnimated:YES];
            [QZUserInfoModel share].invite_mid  = @(111);
            [YBMsgPop showPop:@"邀请码提交成功"];
        }else{
            [YBMsgPop showPop:msg];
        }
    }];
}


@end
